package org.cnc.explain.lifecycle.beaninstance_6;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;

/**
 * <p>
 * #TODO: desc
 * </p>
 *
 * @author zhiyong.tan
 * @since 2022-08-28
 */
public class MyBeforeInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		// 进行实例化前置拦截, 可以在这个阶段返回一个初始化好的Bean
		if(BeanInstanceBean.class.equals(beanClass)){
			System.out.println("Bean实例化前置拦截:" + beanName);
		}
		return InstantiationAwareBeanPostProcessor.super.postProcessBeforeInstantiation(beanClass, beanName);
	}
}
